<template>
    <div class="app-container">
        <el-tabs style='margin-top:15px;' v-model="activeName" type="border-card" v-loading="loading">

            <el-tab-pane label="幻灯片列表" name="slideList" :tab-click="firstTabClick()">
                <el-table
                        :data="slideList"
                        border
                        style="width: 100%">
                    <el-table-column
                            prop="id"
                            label="ID"
                            width="50px">
                    </el-table-column>
                    <el-table-column
                            prop="name"
                            label="姓名">
                    </el-table-column>
                    <el-table-column
                            prop="remark"
                            label="备注">
                    </el-table-column>
                    <el-table-column label="操作" width="250px">
                        <template slot-scope="scope">
                            <el-button
                                    type="primary"
                                    size="small"
                                    @click="handleEdit(scope.row)">编辑</el-button>
                            <el-button
                                    type="primary"
                                    size="small"
                                    @click="handleAddMember(scope.row)">管理页面</el-button>
                            <el-button
                                    type="primary"
                                    size="small"
                                    @click="handleDelete(scope.$index, scope.row)">删除</el-button>
                        </template>
                    </el-table-column>
                </el-table>
            </el-tab-pane>

            <el-tab-pane :label="secondTagName" name="slideAdd">
                <el-form :model="slideInfo" :rules="rules" ref="form" label-width="100px">
                    <el-form-item label="名称" prop="site_seo_title">
                        <el-input v-model="slideInfo.name"></el-input>
                    </el-form-item>
                    <el-form-item label="描述" prop="site_seo_title">
                        <el-input v-model="slideInfo.remark"></el-input>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" @click="submitForm()">保存</el-button>
                    </el-form-item>
                </el-form>
            </el-tab-pane>

        </el-tabs>
    </div>
</template>

<script>
    import { slideList } from '@/api/admin/Setting'
    export default {
      data() {
        return {
          loading: true,
          activeName: 'slideList',
          secondTagName: '',
          slideList: [],
          slideInfo: {
            name: '',
            remark: ''
          },
          rules: {
            name: [
              { required: true, message: '幻灯片名称不能为空', trigger: 'blur' }
            ]
          }
        }
      },
      created() {
        this.secondTagName = '添加幻灯片'
        this.slide()
      },
      methods: {
        slide() {
          this.loading = true
          slideList().then(response => {
            this.slideList = response.data.items
          }).finally(() => {
            this.loading = false
          })
        },
        handleEdit() {
          this.secondTagName = '编辑幻灯片1111'
          this.activeName = 'slideAdd'
        },
        firstTabClick() {
          this.secondTagName = '添加幻灯片123'
        }
      }
    }
</script>